#!/usr/bin/python

import os
import sys
from subcon import Subcon
from optparse import OptionParser

workpath = '/'

if __name__ == '__main__':


    optionParser = OptionParser()
    optionParser.add_option("-c", "--configfile", dest="configfile", 
            help="use configuration file FILE", metavar="FILE", 
            default="/etc/subcon.conf")
    optionParser.add_option("-r", "--release", dest="release", 
            help="update to release number RELEASE", metavar="RELEASE", 
            default=None)
    optionParser.add_option("-o", "--role", dest="role", 
            help="use configuration role ROLE", metavar="ROLE", 
            default=None)
    optionParser.add_option("-d", "--dry-run", dest="dry_run", 
            help="dry run - show pending changes but leave files untouched", action="store_true",
            default=False)
    optionParser.add_option("-n", "--no-sync", dest="do_sync", 
            help="only update configuration - don't sync system image", action="store_false",
            default=True)
    (options,args) = optionParser.parse_args()

    if os.getuid() !=  0:
        print "You must be root to run subcon."
        sys.exit(1)

    subcon = Subcon(options)

    subcon.doUpdate()
